package github.kawaiior.yuanchuxiuzhen.common.block.fire;

import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.entity.Entity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;

public class StrangeFire extends Block {
    protected static final VoxelShape shapeDown = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D);
    private final float fireDamage;
    private final int level;
    private final boolean yang;

    public StrangeFire(float fireDamage, int level, boolean yang) {
        super(AbstractBlock.Properties.create(Material.FIRE, MaterialColor.TNT)
                .doesNotBlockMovement().zeroHardnessAndResistance().setLightLevel((state) -> 15)
                .sound(SoundType.CLOTH));
        this.level = level;
        this.fireDamage = fireDamage;
        this.yang = yang;
    }

    public StrangeFire(float fireDamage, int level) {
        this(fireDamage, level, false);
    }

    public int getLevel() {
        return level;
    }

    @Override
    public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) {
        if (!entityIn.isImmuneToFire()) {
            entityIn.attackEntityFrom(DamageSource.IN_FIRE, this.fireDamage);
        }
    }

    @Override
    public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
        return shapeDown;
    }

    public boolean isYang() {
        return yang;
    }
}
